package VectorApproach;

import java.util.ArrayList;

class Cube{
	ArrayList<Integer> listClusterID = new ArrayList<Integer>();
	public void ACT001_addCluster(int id) {
		this.listClusterID.add(id);
	}
}

public class ClusterSpreadStatistic {
	Cube[][] listCube = null;
	
	public ClusterSpreadStatistic(int cubeLen, int framewidth, int frameheight) {
		this.listCube = new Cube[framewidth/cubeLen][frameheight/cubeLen];
		for(int i = 0; i < this.listCube[0].length; i++) {
			for(int j=0; j < this.listCube.length; j++) {
				this.listCube[j][i] = new Cube();
			}
			System.out.println();
		}
	}
	
	public void ACT001_addNewCluster(int clusterID, int x, int y) {
		this.listCube[x][y].ACT001_addCluster(clusterID);
	}
	
	public void ACT002_showResult() {
		for(int i = 0; i < this.listCube[0].length; i++) {
			for(int j=0; j < this.listCube.length; j++) {
				System.out.printf("%3d ", this.listCube[j][i].listClusterID.size());
			}
			System.out.println();
		}
	}
	
	public void ACT003_filter() {
		ArrayList<Integer> listCandidate = new ArrayList<Integer>();
		for(int i = 0; i < this.listCube[0].length; i++) {
			for(int j=0; j < this.listCube.length; j++) {
				int index = 0;
				int minId = 99999;
				while(index < this.listCube[j][i].listClusterID.size()) {
					Integer getInt = this.listCube[j][i].listClusterID.get(index);
					if(getInt < minId) {
						minId = getInt;
					}
					index = index + 1;
				}
				if(!listCandidate.contains(minId) && minId != 99999 && this.listCube[j][i].listClusterID.size() < 5) {
					if(minId <200)
						listCandidate.add(minId);
				}
			}
		}
		int index = 0;
		while(index < listCandidate.size()) {
			System.out.println(listCandidate.get(index));
			index = index + 1;
		}
	}
}
